package com.app.web.user.myCenter;

import com.app.base.BaseDao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface MyCenterDao extends BaseDao {
    //新增收货地址
    void saveUserAddress(Map<String,Object> map);

    //查询收货地址
    List<Map<String,Object>> selectUserAddress(@Param("uid") long uid, @Param("defaultStatus") int defaultStatus);

    //删除收货地址
    @Delete("DELETE FROM t_user_address WHERE id=#{id} and uid=#{uid}")
    int deleteUserAddress(@Param("uid")long uid,@Param("id") int id);

    //修改收货地址
    int updateUserAddress(Map<String,Object> map);

    @Update("update t_user_address set name=#{name},phone=#{phone},address=#{address},addrInfo=#{addrInfo},is_default = #{defaultStatus} ,province=#{province},city=#{city},county=#{county}where id=#{id} and uid=#{uid}")
    int updateAddressById(Map<String,Object> map);

    @Select("select addrInfo,phone,province,city,county FROM t_user_address WHERE id=#{id} and uid=#{uid}")
    Map<String,Object> addrInfo(@Param("uid")long uid,@Param("id") long id);

}
